package cn.iocoder.yudao.framework.common.enums.pay;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum PayCollectOrderTypeEnum implements ArrayValuable<Integer> {

    WALLET_RECHARGE(0, "钱包充值"),
    PAYMENT(1, "货款支付"),
    ;

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(PayCollectOrderTypeEnum::getType).toArray(Integer[]::new);

    private final Integer type;
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static PayCollectOrderTypeEnum valueOf(Integer type) {
        if (type == null) {
            return null;
        }
        return ArrayUtil.firstMatch(item -> item.getType().equals(type), values());
    }
}
